Add Parallel Agents plugin to run subagents concurrently#1
Add Parallel Agents plugin to run subagents concurrently#1prostonoob wants to merge 2 commits intodevfrom
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a8cd789011
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
.opencode/plugins/parallel-agents.ts
Outdated
| parts: [{ type: "text", text: item.prompt }], | ||
| }, | ||
| }) | ||
| .then((res) => { |
There was a problem hiding this comment.
Catch rejected prompt requests and mark jobs failed
The background client.session.prompt(...) call only uses .then(...) without a rejection handler, so transport-level failures (for example, fetch/network abort errors) leave the job in running forever. In that case agents_wait will keep polling until timeout and never surface the real failure, which makes parallel runs nondeterministic and hard to recover from.
Useful? React with 👍 / 👎.
.opencode/plugins/parallel-agents.ts
Outdated
| jobs: tool.schema.array(tool.schema.string()).optional(), | ||
| }, | ||
| async execute(args) { | ||
| const ids = args.jobs?.length ? args.jobs : Array.from(map.keys()) |
There was a problem hiding this comment.
Scope job status queries to the requesting session
agents_status defaults to Array.from(map.keys()) while map is module-global, so a caller can retrieve jobs (including outputs and session IDs) started by other chats/sessions in the same process. In any shared runtime this leaks cross-session data; statuses should be filtered by owner session (or equivalent access check) before returning results.
Useful? React with 👍 / 👎.
.opencode/plugins/parallel-agents.ts
Outdated
| const jid = id() | ||
| const desc = item.description?.trim() || "parallel task" | ||
|
|
||
| const created = await client.session.create({ |
There was a problem hiding this comment.
Handle session.create rejection per task in agents_start
Each task awaits client.session.create(...) inside a Promise.all, so if one create request rejects, the whole agents_start call rejects and the caller receives no job IDs, even though other tasks may already have been launched. This makes partial failures unrecoverable; create errors should be caught per task and converted into per-job error states instead of aborting the entire batch.
Useful? React with 👍 / 👎.
Motivation
Description
.opencode/plugins/parallel-agents.tswhich implements aParallelAgentsPluginthat exposes toolsagents_start,agents_status, andagents_waitand tracks jobs in an in-memoryMap.agents_startcreates separate sessions and prompts up to 8 subagents in parallel and returns job ids,agents_statusreturns current job state and outputs, andagents_waitpolls until selected jobs finish (with an optional timeout) usingBun.sleepfor polling..opencode/README.parallel-agents.mdwith usage instructions and explains typical flow and how to enable the plugin viaopencode.json.experimental.chat.system.transformhint recommending theagents_start/agents_status/agents_waitflow for multi-task requests.Testing
Codex Task